package com.uton.rfidcontroller.viewmodel.fragment_model;

import com.uton.rfidcontroller.common.GlobalConstants;
import com.uton.rfidcontroller.common.interfaces.INetController;
import com.uton.rfidcontroller.common.interfaces.IPublicController;
import com.uton.rfidcontroller.common.net.RetrofitFactory;
import com.uton.rfidcontroller.model.CarDealerListModel;
import com.uton.rfidcontroller.viewmodel.base.BaseViewModel;

import java.util.HashMap;
import java.util.List;

/**
 * Created by 王家宝 on 2017/9/5.
 * Email:639586819@qq.com
 * Tel:18241150668
 */

public abstract class HasDoTaskViewModel extends BaseViewModel implements IPublicController.IXRefreshController<CarDealerListModel>{

    @Override
    public void refreshData() {
        refreshCarList();
    }

    @Override
    public void doOnLoadMore() {
        super.doOnLoadMore();
    }

    private void refreshCarList() {
        HashMap<String, Object> tempData = new HashMap<>();
        tempData.put("patrolState", GlobalConstants.NO_PATROL);

        go(RetrofitFactory.getInstance().carDealerList(tempData), new INetController<List<CarDealerListModel>>() {
            @Override
            public void onSuccess(List<CarDealerListModel> response) {
                doOnRefreshSuccess(response);
            }

            @Override
            public void onError() {
                doOnRefreshError();
            }

            @Override
            public void onComplete() {

            }
        });
    }

//    private void loadMoreCarList() {
//        mPageNum++;
//        mTempData.put("pageNum", mPageNum);
//        go(RetrofitFactory.getInstance().queryCarList(mTempData), new INetController<List<CarListModel>>() {
//            @Override
//            public void onSuccess(List<CarListModel> response) {
//                doOnLoadMoreSuccess(response);
//            }
//
//            @Override
//            public void onError() {
//                mPageNum--;
//                doOnLoadMoreError();
//            }
//        });
//    }


}
